var app = getApp();
Page({
  data: {
    message: {},
  },
  onLoad: function(e) {
    var that = this;
    var openid = wx.getStorageSync("openid");
    wx.request({
      url: 'https://www.mamingwang.cn/api/adds/informationcheck',
      data: {
        openid: openid,
        id: e.zid
      },
      method: "post",
      success(res) {
        console.log(res)
        if (res.data.code == 22) {
          res.data.data[0].content = res.data.data[0].content.substring(0, 30) + '...'
        }
        that.setData({
          message: res.data.data[0],
          rflg: res.data.data[1].rflg,
          code: res.data.code,
          zid: e.zid
        })
      }
    })
  },
  //支付
  payMoney: function() {
    var that = this;
    var openid = wx.getStorageSync("openid");
    wx.request({
      url: 'https://www.mamingwang.cn/api/paywx/pay',
      data: {
        openid: openid,
        price: 0.01,
        flg: 2,
        zid: this.data.zid
      },
      method: "post",
      success(res) {
        console.log(res)
        //调起支付
        wx.requestPayment({
          'timeStamp': res.data.timeStamp,
          'nonceStr': res.data.nonceStr,
          'package': res.data.package,
          'signType': res.data.signType,
          'paySign': res.data.paySign,
          success: function(res) {
            that.onLoad(that.data.e)
          },
          fail: function(cancel) {},
        })
      }
    })
  },
  //跳转到实名认证
  goRenZheng: function() {
    if (this.data.rflg == 0) {
      wx.navigateTo({
        url: '../../../myID/pay/pay?zid=' + this.data.zid,
      })
    } else if (this.data.rflg == 4) {
      wx.navigateTo({
        url: '../../../myID/renZheng/renZhengIng/renZhengIng?zid=' + this.data.zid,
      })
    } else if (this.data.rflg == 2) {
      wx.navigateTo({
        url: '../../../myID/renZheng/renZhengNoPass/renZhengNoPass',
      })
    } else if (this.data.rflg == 3) {
      wx.navigateTo({
        url: '../../../myID/pay/pay?zid=' + this.data.zid,
      })
    }
  }
})